/**
 * Copyright (c) 2018 开源 All rights reserved.
 * <p>
 * https://www.sxyc.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.renren.controller;

import io.renren.common.utils.Result;
import io.renren.modules.yckj.dto.CateDTO;
import io.renren.modules.yckj.enums.status.CommonStatus;
import io.renren.modules.yckj.enums.type.HotType;
import io.renren.modules.yckj.service.CateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 测试接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/yckj/cate")
@Tag(name = "分类接口")
@AllArgsConstructor
public class ApiCateController {

    private final CateService cateService;

    @GetMapping("hot")
    @Operation(summary = "热门列表")
    @ApiResponse(content = @Content(mediaType = "application/json",
            schema = @Schema(implementation = CateDTO.class)))
    public Result<List<CateDTO>> hot() {
        Map<String, Object> map = new HashMap<>();
        map.put("hot", HotType.YES.getCode());
        map.put("status", CommonStatus.YES.getCode());
        List<CateDTO> list = cateService.list(map);
        return new Result<List<CateDTO>>().ok(list);
    }

    @GetMapping("list")
    @Operation(summary = "获取列表")
    @ApiResponse(content = @Content(mediaType = "application/json",
            schema = @Schema(implementation = CateDTO.class)))
    public Result<List<CateDTO>> list() {
        Map<String, Object> map = new HashMap<>();
        map.put("status", CommonStatus.YES.getCode());
        List<CateDTO> list = cateService.list(map);
        return new Result<List<CateDTO>>().ok(list);
    }

}